﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UserManager.ascx.cs" Inherits="FreshCms.BackEnd.Controls.Systems.User.UserManager" %>
<div id="page-content" class="block">
    <div class="block-header">
        <a href="javascript:void(0)" class="header-title-link">
            <h1>Quản lý người dùng</h1>
        </a>
    </div>

    <div class="col-sm-2"></div>
    <div class="col-sm-9">
        <div class="block">
            <div class="block-title"><h2>Chức năng</h2></div>
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon"><i class="gi gi-envelope"></i></span>
                            <input type="text" id="txtMail" class="form-control" value="<%=mail %>">
                            <span class="input-group-addon">Email</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon"><i class="gi gi-group"></i></span>
                            <asp:DropDownList ID="ddlGroup" runat="server" CssClass="form-control" size="1"></asp:DropDownList>
                            <span class="input-group-addon">Nhóm</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon"><i class="gi gi-nameplate"></i></span>
                            <input type="text" id="txtIndetity" class="form-control" value="<%=iden %>">
                            <span class="input-group-addon">Số CMT</span>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon"><i class="gi gi-iphone"></i></span>
                            <input type="text" id="txtPhone" class="form-control" value="<%=phone %>">
                            <span class="input-group-addon">Số điện thoại</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon"><i class="gi gi-vcard"></i></span>
                            <input type="text" id="txtFullname" class="form-control" value="<%=fullname %>">
                            <span class="input-group-addon">Tên đầy đủ</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon"><i class="gi gi-rotation_lock"></i></span>
                            <asp:DropDownList ID="ddlStatus" runat="server" CssClass="form-control form-control-status" size="1"></asp:DropDownList>
                            <span class="input-group-addon">Trạng thái</span>
                        </div>
                    </div>
                </div>
            </div>

            <div class="form-group text-center">
                <button type="button" id="btnSearch" class="btn btn-sm btn-info"><i class="gi gi-search mr5"></i>Tìm kiếm</button>
                <a href="/BackEnd/?ui=3&sui=1" id="btnAdd" class="btn btn-sm btn-success"><i class="hi hi-plus mr5"></i>Thêm mới</a>
            </div>
        </div>
    </div>

    <div class="table-responsive">
        <table id="" class="table table-hover">
            <thead>
                <tr>
                    <th class="text-center" style="width: 60px;">#</th>
                    <th class="text-center" style="width: 60px;">Id</th>
                    <th style="width: 100px;">Avatar</th>
                    <th>Email</th>
                    <th>Tên đầy đủ</th>
                    <th style="width: 100px;">Nhóm</th>
                    <th style="width: 200px;">Trạng thái</th>
                    <th class="text-center" style="width: 200px;">Thao tác</th>
                </tr>
            </thead>
            <tbody>
                <asp:Repeater ID="rpt" runat="server">
                    <ItemTemplate>
                        <tr>
                            <td class="text-center"><%# Container.ItemIndex + 1 %></td>
                            <td class="text-center"><%# Eval("UserId")%></td>
                            <td><img src="<%# Eval("UserAvatar")%>" width="50" /></td>
                            <td><%# Eval("UserMail")%></td>
                            <td><%# Eval("UserFullname")%></td>
                            <td><%# Eval("GroupName")%></td>
                            <td><asp:Label ID="lblStatus" runat="server" Text=""></asp:Label></td>
                            <td class="text-center">
                                <div class="btn-group">
                                    <a href="/BackEnd/?ui=3&sui=1&id=<%# Eval("UserId") %>" data-toggle="tooltip" title="" class="btn btn-xs btn-default"
                                        data-original-title="Sửa"><i class="gi gi-pen"></i></a>
                                    <div class="btn-group dropup text-left">
                                        <a href="javascript:void(0)" data-toggle="dropdown" class="btn btn-xs btn-default btn-danger dropdown-toggle"><i class="gi gi-remove_2"></i> </a>
                                        <ul class="dropdown-menu dropdown-menu-delete">
                                            <li><a href="javascript:void(0)" onclick="DeleteData(<%# Eval("UserId") %>)">Đồng ý</a></li>
                                            <li><a href="javascript:void(0)">Hủy</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
        </table>
    </div>
</div>

<script>
    $(function() {
        // format color for drop down list
        FormatColorDropList('<%=ddlStatus.ClientID %>');
    });

    $("#btnSearch").bind("click", function () {
        var link = '/BackEnd/?ui=3';
        if($('#txtMail').val().length>0) link = link + '&mail=' + $('#txtMail').val();
        link = link + '&groupid=' + $('#<%=ddlGroup.ClientID %>').val();
        if($('#txtIndetity').val().length>0) link = link + '&iden=' + $('#txtIndetity').val();
        if($('#txtPhone').val().length>0) link = link + '&phone=' + $('#txtPhone').val();
        if($('#txtFullname').val().length>0) link = link + '&fullname=' + $('#txtFullname').val();
        link = link + '&stt=' + $('#<%=ddlStatus.ClientID %>').val();
        window.location.href = link;
    });

    // event Delete Fast in data table
    function DeleteData(id) {
        // call ajax
        var param;
        param = {
            m: "delete",
            ui : <%=panelId %>,
            id: id
        };
        $.ajax({
            url: "/BackEnd/Handler/User.ashx",
            data: param,
            type: "POST",
            dataType: "json",
            beforeSend: function () {
                jWaiting.callWaiting();
            },
            success: function (data) {
                //console.log(data);
                if (data.Success) {
                    jWaiting.callWaitingMessSuccess('Xóa người dùng thành công...', 'reload', true);
                }
                else {
                    jWaiting.callWaitingMessError(data.Message);
                }
            }
        });
    }
</script>